﻿namespace MyCoreLib.Automation.Data.SqlClient.Metadata
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Linq;

    public class SqlStoredProcedureMetadata : ISqlDbObjectMetadata
    {
        public readonly string FullName;

        public readonly IReadOnlyCollection<SqlParameterMetadata> Parameters;

        public SqlStoredProcedureMetadata(string spFullName, IEnumerable<SqlParameter> parameters, IEnumerable<DataTable> resultSetSchemas)
        {
            this.FullName = spFullName;
            this.Parameters = new ReadOnlyCollection<SqlParameterMetadata>(
                    (from p in parameters
                    where !ReferenceEquals(p, null)
                    select new SqlParameterMetadata(p)).ToList());
        }

        string ISqlDbObjectMetadata.FullName
        {
            get { return this.FullName; }
        }

        public override string ToString()
        {
            return FullName;
        }
    }
}
